<template>
	<view>
		<van-field label="公司名" input-align="right" data-type="phone" right-icon="edit" @change="onChange" placeholder="请输入公司名" />
		<van-field label="请输入公司地址" input-align="right" data-type="phone" right-icon="edit" @change="onChange" placeholder="请输入请输入公司地址" />
		<van-field label="联系人" input-align="right" data-type="phone" right-icon="edit" @change="onChange" placeholder="请输入联系人" />
		<van-field label="联系方式" type="digit" input-align="right" data-type="phone" right-icon="edit" @change="onChange" placeholder="请输入联系电话" />
		
		<van-cell-group title="备注">
			<van-field type="textarea" autosize data-type="phone" @change="onChange"
			 right-icon="edit" placeholder="请输入备注" />
		</van-cell-group>
		<view style="background-color: #fff;padding: 10px; 16px">
			<van-uploader
			  :file-list="fileList"
			  max-count="20"
			  @after-read="afterRead"
			/>
		</view>
		
		<view style="text-align: center; margin: 20px 0;">
			<van-button :color="primaryColor" size="large" @click="onSubmit">确认提交</van-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				primaryColor: getApp().globalData.primaryColor,
				showSexSheet: false,
				sex:'请点击选择',
				showDriverCardSheet: false,
				driverCard: '请点击选择',
				fileList:[]
			};
		},
		methods:{
			afterRead(){
				const { file } = e.detail;
				console.log(file)
				    // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				wx.uploadFile({
				  url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
				  filePath: file.path,
				  name: 'file',
				  formData: { user: 'test' },
				  success(res) {
					// 上传完成需要更新 fileList
					console.log(res)
					this.fileList.push({ ...file, url: res.data });
					this.setData({ fileList });
				  }
				});
			},
			onSubmit(){
				//req
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
